﻿using System;
using AI;
using UnityEngine;
using UnityEngine.Networking;

// Token: 0x020001C4 RID: 452
public class Humanoid : EntityBase
{
	// Token: 0x17000149 RID: 329
	// (get) Token: 0x0600097E RID: 2430 RVA: 0x00056B52 File Offset: 0x00054D52
	// (set) Token: 0x0600097F RID: 2431 RVA: 0x00056B5A File Offset: 0x00054D5A
	public bool poseMode { get; private set; }

	// Token: 0x06000980 RID: 2432 RVA: 0x00056B64 File Offset: 0x00054D64
	protected override void Awake()
	{
		this.isHumanoid = true;
		base.Awake();
		this.poseMode = false;
		this.actionManager = base.gameObject.AddComponent<ActionController>();
		this.anim = base.GetComponent<Animator>();
		this.senses = new SenseController(this);
		this.ai = base.gameObject.GetComponent<AIController>();
		if (this.ai == null)
		{
			this.ai = base.gameObject.AddComponent<AIController>();
		}
		this.ai.Initialize(this);
		this.head = this.anim.GetBoneTransform(HumanBodyBones.Head);
		this.leftEye = this.anim.GetBoneTransform(HumanBodyBones.LeftEye);
		this.rightEye = this.anim.GetBoneTransform(HumanBodyBones.RightEye);
	}

	// Token: 0x06000981 RID: 2433 RVA: 0x00056C26 File Offset: 0x00054E26
	protected virtual void OnDestroy()
	{
		UnityEngine.Object.Destroy(base.GetComponent<ActionController>());
		this.ai.behaviorController.StopAllBehaviors();
		UnityEngine.Object.Destroy(base.GetComponent<AIController>());
		UnityEngine.Object.Destroy(base.GetComponent<AnimationManager>());
	}

	// Token: 0x06000982 RID: 2434 RVA: 0x00056C5C File Offset: 0x00054E5C
	public override Vector3 GetEyesPosition()
	{
		if (this.head != null)
		{
		}
		if (this.leftEye != null && this.rightEye != null)
		{
			return (this.leftEye.position + this.rightEye.position) * 0.5f;
		}
		return this.head.position;
	}

	// Token: 0x06000983 RID: 2435 RVA: 0x00056CD0 File Offset: 0x00054ED0
	public virtual void SetPoseMode(bool value)
	{
		if (this.poseMode != value)
		{
			this.poseMode = value;
			Vector3 position = this.myTransform.position;
			if (this.poseMode)
			{
				AnimationManager.SetAnimatorController(this.anim, IOManager.Instance.poseAnimatorController);
			}
			else
			{
				AnimationManager.SetAnimatorController(this.anim, IOManager.Instance.gtsAnimatorController);
			}
			this.myTransform.position = position;
			if (this.ik != null)
			{
				this.ik.SetPoseMode(this.poseMode);
			}
			else
			{
				Debug.LogWarning("No IK found yet");
			}
		}
	}

	// Token: 0x06000984 RID: 2436 RVA: 0x00056D73 File Offset: 0x00054F73
	public Vector3 GetHumonoidPosition()
	{
		return this.myTransform.position;
	}

	// Token: 0x06000985 RID: 2437 RVA: 0x00056D80 File Offset: 0x00054F80
	public void StayAtLockedScale(Transform selfTransform, float intendedScale)
	{
		Transform parent = selfTransform.parent;
		selfTransform.parent = null;
		selfTransform.localScale = Vector3.one * intendedScale;
		selfTransform.parent = parent;
	}

	// Token: 0x06000986 RID: 2438 RVA: 0x00056DB5 File Offset: 0x00054FB5
	public virtual bool CanDecide()
	{
		return !this.isDead;
	}

	// Token: 0x06000987 RID: 2439 RVA: 0x00056DC0 File Offset: 0x00054FC0
	public Animator GetAnimator()
	{
		return this.anim;
	}

	// Token: 0x06000988 RID: 2440 RVA: 0x00002973 File Offset: 0x00000B73
	private void UNetVersion()
	{
	}

	// Token: 0x06000989 RID: 2441 RVA: 0x00056DC8 File Offset: 0x00054FC8
	public override bool OnSerialize(NetworkWriter writer, bool forceAll)
	{
		bool flag = base.OnSerialize(writer, forceAll);
		bool flag2;
		return flag2 || flag;
	}

	// Token: 0x0600098A RID: 2442 RVA: 0x00056DE1 File Offset: 0x00054FE1
	public override void OnDeserialize(NetworkReader reader, bool initialState)
	{
		base.OnDeserialize(reader, initialState);
	}

	// Token: 0x04000F19 RID: 3865
	protected Animator anim;

	// Token: 0x04000F1A RID: 3866
	private Transform head;

	// Token: 0x04000F1B RID: 3867
	private Transform leftEye;

	// Token: 0x04000F1C RID: 3868
	private Transform rightEye;
}
